# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=bower
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.8.8
pkgrel=1
pkgdesc="A package manager for the web (mingw-w64)"
arch=('any')
url="https://bower.io/"
license=("MIT")
depends=("${MINGW_PACKAGE_PREFIX}-nodejs")
makedepends=("${MINGW_PACKAGE_PREFIX}-nodejs")
source=(https://registry.npmjs.org/${_realname}/-/${_realname}-${pkgver}.tgz)
sha512sums=('d52ac99d79e43fdb282131e9b523be6a1c7740aa77715ce7f29a08eae8ea73949e3a48398aa335a4af47f8349cd8e43c4a73b48c2fcd1b852bfd4230cbbe7be0')

package() {
  npm install -g --user root --prefix "${pkgdir}${MINGW_PREFIX}" "${srcdir}"/${_realname}-${pkgver}.tgz
  rm -r "${pkgdir}${MINGW_PREFIX}/etc"

  cd "${srcdir}/package"
  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"

  local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})

  # fix path in command files
  sed -e "s/\*CYGWIN\*/\*CYGWIN\* | \*MINGW\*/g" -i "${pkgdir}${MINGW_PREFIX}/bin/bower"
}
